﻿package com.vicentediaz.view.leftrightbuttons
{
    import com.greensock.*;
    import com.vicentediaz.data.*;
    import flash.display.*;
    import flash.events.*;

    public class ButtonLeft extends Sprite
    {
        private var shape:ButtonLeftShape;
        private const LEFT:uint = 20;

        public function ButtonLeft()
        {
            this.shape = new ButtonLeftShape();
            this.shape.x = -this.shape.width;
            addChild(this.shape);
            addEventListener(MouseEvent.ROLL_OVER, this.onButtonRollOver, false, 0, true);
            addEventListener(MouseEvent.ROLL_OUT, this.onButtonRollOut, false, 0, true);
            buttonMode = true;
            return;
        }// end function

        private function onButtonRollOut(param1:MouseEvent) : void
        {
            TweenMax.to(this.shape, 0.2, {x:-this.LEFT});
            return;
        }// end function

        private function onButtonRollOver(param1:MouseEvent) : void
        {
            TweenMax.to(this.shape, 0.2, {x:0});
            Sounds.getInstance().playById("PAPER", 0.05, (-(stage.stageWidth / 2 - stage.mouseX)) / stage.stageWidth);
            return;
        }// end function

        public function hide() : void
        {
            TweenMax.to(this.shape, 0.3, {x:-this.shape.width});
            return;
        }// end function

        public function show() : void
        {
            TweenMax.to(this.shape, 0.3, {x:-this.LEFT});
            return;
        }// end function

    }
}
